﻿using Microsoft.Extensions.DependencyInjection;

namespace Luka;

/// <summary>
/// 路由设置
/// </summary>
[NotScanned]
public static class RouteSetup
{
    /// <summary>
    /// 添加路由约束
    /// </summary>
    /// <param name="prefix">路由前缀</param>
    /// <returns></returns>
    public static IServiceCollection AddRouteConvention(this IServiceCollection services)
    {
        string prefix = InternalApp.GetSection("RoutePrefix");
        services.AddMvc(opt =>
        {
            opt.Conventions.Insert(0, new RouteConvention(prefix));
        });
        return services;
    }
}